<template>
	<view class="container">
		
		<view class="item" v-for="(item,index) in list" @click="handleClick(item.id)">

			<view class="content">
				{{index+1}}.
				{{item.title}}
			</view>
			<view class="contentTime">
				{{item.createTime}}
			</view>

		</view>
		<view v-if="!ispatient">
			<button class="addhealth" @click="addhealth()">
				<image class="addImg" src="../../static/add.png"></image>
			</button>
		</view>
	</view>
</template>

<script>
	import { getList } from '@/api/index.js'
	export default {
		data() {
			return {
				list: [],
				ispatient: false
			}
		},
		onLoad() {
			this.ispatient = uni.getStorageSync('user').patient
		},
		onShow(){
			this.getDataList()
		},
		methods: {
			handleClick(id) {
				uni.navigateTo({
					url: '/pages/health/info?id='+id
				})
			},
			//新增医疗保健知识
			addhealth() {
				uni.navigateTo({
					url: '/pages/health/addhealth'
				})
			},
			getDataList() {
				let param = {
					current: 1,
					size: 1000
				}
				getList(param).then(res => {
					if(res.code !== 200) {
						uni.showToast({
							title:res.message,
							icon:'none'
						})
						return
					}
					this.list = res.data.rows
				})
			}
		}
	}
</script>

<style>
	
	.item {
		padding: 20rpx;
		color: #545454;
		margin-bottom: 5rpx;
		border-top: 1px solid #f5f5f5;
		border-bottom: 1px solid #f5f5f5;;
	}
	.content {
		display: flex;
		flex-direction: column;
	}
	.contentTime {
		margin-top: 20rpx;
		color: #999999;
		font-size: small;
		text-align: end;
	}
	
	.addhealth {
		background-color: rgba(74,141,156,0.9);
		color: white;
		position: fixed;
		 width: 100rpx;
		 height: 100rpx;
		 bottom: 110rpx;
		 right: 0%;
		 border-radius: 100rpx;
		 display: flex;
		 align-items: center;
		 justify-content: center;
	}
	.addImg {
		height: 50rpx;
		width: 50rpx;
	}
	 
</style>
